package com.hdoit.apollo.logical.cargo.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hdoit.apollo.logical.cargo.dao.ICollocationDao;
import com.hdoit.apollo.logical.cargo.mapper.CollocationMapper;
import com.hdoit.apollo.logical.cargo.model.Collocation;
import com.tennetcn.data.dao.base.ISqlExpression;
import com.tennetcn.data.dao.base.impl.SuperDao;
import com.tennetcn.data.utils.SqlExpressionFactory;
/**
 * @author      humaoshu
 * @email       
 * @createtime  2018年04月02日 11:21:34
 * @comment
 */
@Component
public class CollocationDaoImpl extends SuperDao<Collocation> implements ICollocationDao{

	@Autowired
	private CollocationMapper collocationMapper;
	
	@Override
	public List<Collocation> queryListByCargoId(String cargoId) {

		return collocationMapper.queryListByCargoId(cargoId);
	}

	@Override
	public boolean deleteByCargoId(String cargoId) {
		ISqlExpression sqlExpression = SqlExpressionFactory.createExpression();
		sqlExpression.addBody("delete from",Collocation.class)
					.andWhere("cargoId=#{cargoId}")
					.setParam("cargoId", cargoId);
		return delete(sqlExpression)>=0;
	}

	@Override
	public Collocation queryModelByCargo(String collocationId) {
		
		return collocationMapper.queryModelByCargo(collocationId);
	}

	@Override
	public List<Collocation> queryListForWechatByCargoId(String cargoId,
			String shopId) {
		
		return collocationMapper.queryListForWechatByCargoId(cargoId,shopId);
	}

}